const map: Map<number, string | undefined> = new Map([
  [65, 'A'],
  [66, 'B'],
  [67, 'C'],
  [68, 'D'],
  [69, 'E'],
  [70, 'F'],
  [71, 'G'],
  [72, 'H'],
  [73, 'I'],
  [74, 'J'],
  [75, 'K'],
  [76, 'L'],
  [77, 'M'],
  [78, 'N'],
  [79, 'O'],
  [80, 'P'],
  [81, 'Q'],
  [82, 'R'],
  [83, 'S'],
  [84, 'T'],
  [85, 'U'],
  [86, 'V'],
  [87, 'W'],
  [88, 'X'],
  [89, 'Y'],
  [90, 'Z'],
  [65, 'a'],
  [66, 'b'],
  [67, 'c'],
  [68, 'd'],
  [69, 'e'],
  [70, 'f'],
  [71, 'g'],
  [72, 'h'],
  [73, 'i'],
  [74, 'j'],
  [75, 'k'],
  [76, 'l'],
  [77, 'm'],
  [78, 'n'],
  [79, 'o'],
  [80, 'p'],
  [81, 'q'],
  [82, 'r'],
  [83, 's'],
  [84, 't'],
  [85, 'u'],
  [86, 'v'],
  [87, 'w'],
  [88, 'x'],
  [89, 'y'],
  [90, 'z'],
  [48, '0'],
  [49, '1'],
  [50, '2'],
  [51, '3'],
  [52, '4'],
  [53, '5'],
  [54, '6'],
  [55, '7'],
  [56, '8'],
  [57, '9'],
  [96, '0'],
  [97, '1'],
  [98, '2'],
  [99, '3'],
  [100, '4'],
  [101, '5'],
  [102, '6'],
  [103, '7'],
  [104, '8'],
  [105, '9'],
  [106, '*'],
  [107, '+'],
  [108, 'Enter'],
  [109, '-'],
  [110, '.'],
  [111, '/'],
  [112, 'F1'],
  [113, 'F2'],
  [114, 'F3'],
  [115, 'F4'],
  [116, 'F5'],
  [117, 'F6'],
  [118, 'F7'],
  [119, 'F8'],
  [120, 'F9'],
  [121, 'F10'],
  [122, 'F11'],
  [123, 'F12'],
  [8, 'BackSpace'],
  [9, 'Tab'],
  [12, 'Clear'],
  [13, 'Enter'],
  [16, 'Shift'],
  [17, 'Control'],
  [18, 'Alt'],
  [20, 'CapsLock'],
  [27, 'Escape'],
  [32, ' '],
  [33, 'PageUp'],
  [34, 'PageDown'],
  [35, 'End'],
  [36, 'Home'],
  [37, 'ArrowLeft'],
  [38, 'ArrowUp'],
  [39, 'ArrowRight'],
  [40, 'ArrowDown'],
  [45, 'Insert'],
  [46, 'Delete'],
  [144, 'NumLock'],
  // 以下备注的快捷键是因为中英文输入法状态下结果不一样
  // 这里默认使用英文输入法状态下的字符名称
  // ;:
  [186, ';'],
  // +=
  [187, '+'],
  // ,<
  [188, ','],
  // -_
  [189, '-'],
  // .>
  [190, '.'],
  // /?
  [191, '/'],
  // `~
  [192, '`'],
  // [{
  [219, '['],
  // \|
  [220, '\\'],
  // ]}
  [221, ']'],
  // "'
  [222, '"'],
  [173, 'AudioVolumeMute'],
  [174, 'AudioVolumeDown'],
  [175, 'AudioVolumeUp'],
  [176, 'MediaTrackNext'],
  [177, 'MediaTrackPrevious'],
  [179, 'MediaPlayPause'],
  [181, 'LaunchMediaPlayer'],
  [182, 'LaunchApplication1'],
  [183, 'LaunchApplication2']
])
/**
 * 根据 键盘代码 获取 键盘名称
 *
 * @param code 键盘代码
 * @return 键盘名称
 */
const getNameByCode = (code): string | undefined => {
  return map.get(code)
}

export { getNameByCode }
